<?php
/*
Cogumelo v0.1 - Map-Experience
Copyright (C) 2008 Innoto Gestión para el Desarrollo Social S.L. <mapinfo@map-experience.com>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
USA.
*/


//
// Administrator User Value Object
//


// Predefine security access levels
define('USERADMIN_LEVEL_HIGH',3);
define('USERADMIN_LEVEL_MEDIUM',2);
define('USERADMIN_LEVEL_LOW',1);

class UseradminVO 
{
	private $id;	
	private $login;	
	private $name;
	private $passwd;	
	private $timeLastLogin;
	private $level;
	private $timelastchangepasswd;
	private $oldpassword1;
	private $oldpassword2;
	private $oldpassword3;
		
	//
	//	useradminVO Constructor
	//	
	function __construct(
					$id = 0,					
					$login = "",					 
					$passwd = "",						
					$name = "",
					$TimeLastLogin = 0,
					$level = 1,
					$timelastchangepasswd = 0,
					$oldpassword1 =	"",
					$oldpassword2 = "",
					$oldpassword3 = ""
					) 
	{
			
		$this->id = $id;		
		$this->login = $login;
		$this->name = $name;		
		$this->passwd = $passwd;		
		$this->timeLastLogin = $timeLastLogin;
		$this->level = $level;
		$this->timelastchangepasswd = $timelastchangepasswd;
		$this->oldpassword1 = $oldpassword1;
		$this->oldpassword2 = $oldpassword2;
		$this->oldpassword3 = $oldpassword3;	
	}
	
	///////////////////////////////////////
	///////	Get Methods	//////////////////
	/////////////////////////////////////

	function getId()
	{
		return $this->id;
	}
	
	function getLogin()
	{
		return $this->login;
	}

	function getEmail()		//For Log system compatibility
	{
		return $this->login;
	}
	
	function getPasswd()
	{
		return $this->passwd;
	}
	
	function getName()
	{
		return $this->name;
	}
		
	function getTimeLastLogin()
	{
		return $this->timeLastLogin;
	}
	
	function getLevel()
	{
		return $this->level;
	}
	
	function getTimelastchangepasswd()
	{
		return $this->timelastchangepasswd;
	}
	function getOldpassword1()
	{
		return 	$this->oldpassword1;
	}
	function getOldpassword2()
	{
		return $this->oldpassword2;
	}
	function getOldpassword3()
	{
		return $this->oldpassword3;
	}	
	
	function isLevelHigh()
	{
	  return($this->level==USERADMIN_LEVEL_HIGH);
	}
	
	function isLevelMedium()
	{
	  return($this->level==USERADMIN_LEVEL_MEDIUM);
	}
	
	function isLevelLow()
	{
	  return($this->level==USERADMIN_LEVEL_LOW);
	}
	
	function getTimeLastLogin_print()
	{
		$date = explode( ' ', $this->timeLastLogin);
		$datepart = explode( '-', $date[0]);
		$day = $datepart[2]; $month = $datepart[1]; $year = $datepart[0];
		return($day."/".$month."/".$year);
	}
	
	///////////////////////////////////////
	///////	Set	Methods	//////////////////
	/////////////////////////////////////	
	function setId($id)
	{
		$this->id = $id;
	}
	
	function setLogin($login)
	{
		$this->login = $login;
	}
	
	function setName($name)
	{
		$this->name = $name;
	}
		
	function setPasswd($passwd)
	{
		$this->passwd = $passwd;
	}
	
	function setLevel($level)
	{
		$this->level = $level;
	}
	
	function setLevelHigh()
	{
		$this->level = USERADMIN_LEVEL_HIGH;
	}
	
	function setLevelMedium()
	{
		$this->level = USERADMIN_LEVEL_MEDIUM;
	}
	
	function setLevelLow()
	{
		$this->level = USERADMIN_LEVEL_LOW;
	}
	
	function setTimeLastLogin($timeLastLogin)
	{
		$this->timeLastLogin = $timeLastLogin;
	}
	
	function setTimelastchangepasswd ($timelastchangepasswd)
	{
		$this->timelastchangepasswd = $timelastchangepasswd;
	}
	function setOldpassword1 ($oldpassword1)
	{
		$this->oldpassword1 = $oldpassword1;
	}
	function setOldpassword2 ($oldpassword2)
	{
		$this->oldpassword2 = $oldpassword2;
	}
	function setOldpassword3 ($oldpassword3)
	{
		$this->oldpassword3 = $oldpassword3;	
	}
	public function toString()
	{
		$str = "\n\n useradminVO:".$this->id.
		"\n Id. ".$this->id.
		"\n Login. ".$this->login.		
		"\n Name. ".$this->name.
		"\n Level. ".$this->level.		
		"\n timelastlogin. ".$this->timeLastLogin.
		"\n\n";
		
		return $str;
 	}
}
?>